import http from "@/utils/http"
// @ts-ignore
import type {img} from "@/components/ImgUpload/index.vue";

const BaseUrl = "/hanfu"

export interface file {
    ossId: number
    fileType: string
    clientUrl: string
}

export interface HanFuQuery {
    /**
     * 汉服类型名称
     * */
    hanFuTypeName: string | null

    /**
     * 汉服名称
     * */
    hanFuName:string | null

    /**
     * 汉服状态
     * */
    hanFuStatus: number | null

    /**
     * 页码
     * */
    pageNum: number | 1

    /**
     * 每页数据量
     * */
    pageSize: number | 10
}

export interface HanFuVo {
    id: number,

    /**
     * 汉服类型id
     */
    typeId: number,

    /**
     * 汉服类型名称
     */
    typeName: string,

    /**
     * 汉服名称
     */
    name:string,

    /**
     * 汉服价格
     */
    price:number,

    file: file[]

    /**
     * 更新者
     */
    updataBy:string,

    /**
     * 更新时间
     */
    updataTime:string,

    /**
     * 1启用 0 不启用
     */
     status:number,
}

export interface hanfuDto {
    id: number,
    typeId:number,
    name:string,
    price:string,
    ossId:string,
    /**
     * 描述
     */
    description:string,
    file: File[]
    updataBy:string,
    status:number,
    typeName?: string
}

export function getHanfuListByCondition(query:HanFuQuery) {
    return  http.post<Page<HanFuVo[]>>(`${BaseUrl}/condition`, query)
}

export function addHanfu(data:FormData){
    return http.post<void>(`${BaseUrl}`,data)
}

export function delHanfu(ids:number[]){
    return http.del(`${BaseUrl}`,ids)
}

export function putHanfu(data:hanfuDto) {
    return http.put(`${BaseUrl}`,data)
}

export function putHanFuImg(data:FormData) {
    return http.put(`${BaseUrl}/img`,data)
}